<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function Login(){
        if(IS_POST){
            
         $user=M('sysuser');
         $map['username']=I('post.username');
         $ck=$user->where($map)->find();
         if($ck){
             
          if($ck['password']==MD5(I('post.password'))){
             session('username',$ck['username']);
             session('tk_qx',$ck['tk_qx']);
             session('qx',$ck['qx']);
              $this->success('登录成功,正在转向系统管理页',U('Index/index'));
              $data['ip']=get_client_ip();
              $data['logintime']=date('Y-m-d H:i:s');
              $data['user']=I('post.username');
              $add=M('loginlog')->add($data);
          }   else{
              
              $this->error('对不起密码输入错误');
          }
             
         }else{
             
          $this->error('您输入的账号不存在');   
         }
            
        }else{
        $this->display();
        }
        
    }
   
public function logout(){
	$S=session('empid',NULL);
	
		
	$this->success('您已成功退出登录',U('Login/Login'))	;
		
	echo '<script>window.close();</script>'; 
	
	
}	
}

?>